Ext.namespace('Taxamatch');
Ext.namespace('Taxamatch.ux');

Ext.data.DataProxy.addListener('exception', function(proxy, type, action, options, res) {
    if (type === 'remote') {
       	Taxamatch.Notice.msg('Error', 'Unable to process.');
    }
});

Ext.data.DataProxy.addListener('write', function(proxy, action, result, res, rs) {
		if(res.success){
				switch(res.action) {
						case 'destroy':
							Taxamatch.Notice.msg('Sucess', 'Database ' + rs.data.name + ' sucessfully deleted.');	
							break;
						case 'update':
							Taxamatch.Notice.msg('Sucess', 'Database ' + rs.data.name + ' sucessfully updated.');	
							break;
						case 'create':
							Taxamatch.Notice.msg('Sucess', 'Database ' + rs.data.name + ' sucessfully created.');	
							break;	
					}
		}else{
				Ext.Msg.alert('Error', 'Unable to process.');
		}
});


Taxamatch.ux.UserGrid = Ext.extend(Ext.grid.EditorGridPanel, {
			initComponent : function() {
					// typical viewConfig
					this.viewConfig = {
						    forceFit: true
						};
					this.relayEvents(this.store, ['destroy', 'save', 'update']);
					Taxamatch.ux.UserGrid.superclass.initComponent.call(this);
				}
		});
